library("foreign")
library("arm")
library("ggplot2")
setwd('d:/r')
c739 <- read.spss('brawl 2017 for figure 4.sav')
m1 <- lm(q6_w21~male+nage+edu_uni+edu_post+area_central+area_south+career_public+
  + career_manage+career_clerk+ethnic_hakka+ethnic_mainlander+ui_unify+ui_indep+
  + identity_taiwanese+kbetter+I(kbetter*kbetter), data=c739)
summary(m1)
c1 <- ggplot(m1,aes(x=kbetter, y=q6_w21)) + 
  stat_smooth(method=lm, formula=y~poly(x,2))+
  geom_vline(xintercept=3.5)+
  xlab("KMT thermometer minus DPP thermometer")+
  ylab("increase in legislative performance")+
  ggtitle("change from wave 1 to wave 2 (Table A5.1, Model 1)")+
  coord_cartesian(ylim = c(-1.1, 1.6))
c1

m2 <- lm(q6_w32~male+nage+edu_uni+edu_post+area_central+area_south+career_public+
  + career_manage+career_clerk+ethnic_hakka+ethnic_mainlander+ui_unify+ui_indep+
  + identity_taiwanese+kbetter+I(kbetter*kbetter), data=c739)
summary(m2)
c2 <- ggplot(m2,aes(x=kbetter, y=q6_w32)) + 
  stat_smooth(method=lm, formula=y~poly(x,2))+
  geom_vline(xintercept=3.5)+
  xlab("KMT thermometer minus DPP thermometer")+
  ylab("increase in legislative performance")+
  ggtitle("change from wave 2 to wave 3 (Table A5.1, Model 2)")+
  coord_cartesian(ylim = c(-1.1, 1.6))
c2



m3 <- lm(q22_w21~male+nage+edu_uni+edu_post+area_central+area_south+career_public+
  + career_manage+career_clerk+ethnic_hakka+ethnic_mainlander+ui_unify+ui_indep+
  + identity_taiwanese+kbetter+I(kbetter*kbetter), data=c739)
summary(m3)
c3 <- ggplot(m3,aes(x=kbetter, y=q22_w21)) + 
  stat_smooth(method=lm, formula=y~poly(x,2))+
  geom_vline(xintercept=3.5)+
  xlab("KMT thermometer minus DPP thermometer")+
  ylab("increase in how well democracy is working")+
  ggtitle("change from wave 1 to wave 2 (Table A5.1, Model 3)")+
  coord_cartesian(ylim = c(-1.1, 1.6))
c3



m4 <- lm(q22_w32~male+nage+edu_uni+edu_post+area_central+area_south+career_public+
  + career_manage+career_clerk+ethnic_hakka+ethnic_mainlander+ui_unify+ui_indep+
  + identity_taiwanese+kbetter+I(kbetter*kbetter), data=c739)
summary(m4)
c4 <- ggplot(m4,aes(x=kbetter, y=q22_w32)) + 
  stat_smooth(method=lm, formula=y~poly(x,2))+
  geom_vline(xintercept=3.5)+
  xlab("KMT thermometer minus DPP thermometer")+
  ylab("increase in how well democracy is working")+
  ggtitle("change from wave 2 to wave 3 (Table A5.1, Model 4)")+
  coord_cartesian(ylim = c(-1.1, 1.6))
c4


  